Type 2 diabetes is a major public health concern in Scotland, with its prevalence rising by approximately 40% in the last decade (Colhoun & McKnight, 2020). Effective medication management is important for preventing complications and reducing healthcare burden associated with the condition. Prescribing patterns therefore provide valuable insights into population health, but they are sensitive to changes in healthcare access, media influence and wider social conditions.
The COVID-19 pandemic introduced unprecedented disruption to daily life. Lockdowns contributed to lifestyle changes associated with increased metabolic risk, while restricted access to healthcare may have affected diagnosis and routine management, which may have impacted existing socioeconomic disparities. Diabetes prevalence is 80% higher in the most deprived fifth of the population than in the fifth most affluent, and the gap is widening (Colhoun & McKnight, 2020).
This report examines how prescribing of common Type 2 medications changed during the COVID-19 pandemic across Scotland. The aim is to assess whether the pandemic altered prescribing patterns, and whether these changes differed by levels of socioeconomic deprivation.
Prescription data were obtained from Public Health Scotland’s Prescriptions in the Community dataset, specifically the “Data by Prescriber Location” records, covering the period from January 2020 to December 2021. Population estimates were drawn from the National Records of Scotland 2022 census release (Table UV302: General Health, Health Board Area, 2019). Socioeconomic deprivation was assessed using the Scottish Index of Multiple Deprivation (SIMD) 2020v2 data zone lookup file. NHS Scotland health board boundaries were incorporated using publicly available shapefiles to enable spatial analysis and visualisation in prescribing across regions.
The data was then filtered for type 2 diabetes medications including biguanides (metformin), SGLT2 inhibitors (gliflozins), sulphonylureas (gliclazide, glimepiride), DDP-4 inhibitors (gliptins), GLP-1 receptor agonists (glutides), thiazolidinediones (glitazone), with all available formulations. These filtered data were then processed to generate visual summaries and descriptive analyses.
For the purpose of this study, the COVID-19 period is defined as March 2020 to June 2021, covering the introduction of national lockdown measures through to the lifting of major covid restrictions.
library(tidyverse)
library(janitor) # cleaning data
library(gt) # to create pretty tables
library(here) # directory structure
library(readxl) # read in excel file
library(sf) # to read in map data
library(plotly) # for interactive plot
library(scales) # to add colour scheme
# Get data from 24-month period from Jan 2020 - Dec 2021
# Create function to read data in:
prescriptions_data <- function() {
files <- c(paste0(c("jan", "feb","mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"), "2020"),
paste0(c("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"), "2021"))
map_dfr(files, ~read_csv(here("data", paste0(.x, ".csv"))) %>%
clean_names() %>%
mutate(file_name = .x))}
# Read in data
data_for_years <- prescriptions_data()
deprivation_stats <- read_excel(here("data/SIMD.xlsx"))# Read in and tidy health board population database
population_data <- read_csv(here("data/general_health_census.csv"), skip = 10) %>%
filter(!is.na('All people')) %>% # Removes NA
rename(hb_name = "General health",
hb_population = "All people") %>%
select(hb_name, hb_population) %>%
filter(!str_detect(hb_population, "Cells")) # Removes rows with text in population (to remove copyright info from data)The results are structured to show how Type 2 diabetes prescribing changed during and after the COVID-19 pandemic across Scotland. Temporal trends are presented first, followed by comparisons of absolute and percentage changes across Health Boards. A final summary table integrates these measures to illustrate variation across Scotland.
First, to understand the overall pattern of prescribing during the COVID-19 pandemic, monthly prescribing rates from January 2020 to December 2022 were examined for each Health Board. Line plots were generated using free y-scales to account for substantial differences in prescription volume between Health Boards, ensuring that trends within boards were more easily comparable.
# Filter for diabetes medications
diabetes_summary <- data_for_years %>%
filter(!is.na(bnf_item_description)) %>%
filter(str_detect(bnf_item_description,
regex("metformin|gliptin|gliflozin|glutide|glitazone|gliclazide|glimepiride", ignore_case = TRUE))) %>% # Search for common diabetes medications whilst ignoring upper and lower cases
group_by(paid_date_month, hbt) %>%
summarise(paid_quantity = sum(paid_quantity, na.rm = TRUE)) %>%
mutate(paid_date_month = ym(paid_date_month)) # Format dates
# Merge all tables together
combined_health_data <- deprivation_stats %>%
full_join(diabetes_summary, join_by(HBcode == hbt)) %>%
left_join(population_data, join_by(HBname == hb_name))
# Calculate prescriptions per person
combined_health_data <- combined_health_data %>%
group_by(HBname, paid_date_month) %>%
mutate(quantity_per_head = paid_quantity / mean(as.numeric(hb_population))) # Calculate prescriptions per person and change hb_population to numeric value instead of character# Plot diabetes summary table, highlighting COVID-19 period
meds_per_month <- combined_health_data %>%
ggplot(aes(x = paid_date_month, y = quantity_per_head)) +
# Add vertical lines for COVID start and end
geom_vline(xintercept = as.numeric(ymd("2020-03-01")),
linetype = "dashed", colour = "orange") +
geom_vline(xintercept = as.numeric(ymd("2021-06-01")),
linetype = "dashed", colour = "orange") +
geom_line(colour = "purple") +
labs(
title = "Type 2 diabetes medications per person across Scotland NHS Healthboards",
subtitle = "January 2020 - December 2021 | Orange dashed lines: COVID-19 period (Mar 2020 - Jun 2021)",
x = "Month",
y = "Quantity per head") +
theme_light() +
theme(axis.text.x = element_text(angle = 45, hjust=1),
plot.title = element_text(face = "bold"))+
facet_wrap(~HBname, scales = "free_y")
meds_per_month #display resultAll Health Boards showed a marked decline in prescribing at the onset of COVID-19 in March 2020, followed by gradual recovery. However, there was variation in the number of timing of subsequent troughs during the COVID-19 period, with most experiencing notable dips in early 2021. Overall, prescribing levels increased across all boards when comparing pre- and post- pandemic periods.
To quantify these changes, January 2020 was selected as the pre-COVID baseline baseline and December 2022 as the post-pandemic comparison point. These timepoints reduce the influence of seasonal variation and allow for consistent comparison between more and less deprived areas. Absolute changes between pre-COVID and post-COVID prescribing were calculated and ordered by deprivation rank.
# Create table with pre and post COVID values
key_months_data <- combined_health_data %>%
filter(paid_date_month %in% as.Date(c("2020-01-01", "2021-12-01"))) %>%
group_by(HBname) %>%
mutate(covid_phase = case_when(
paid_date_month == as.Date("2020-01-01") ~ "pre_covid",
paid_date_month == as.Date("2021-12-01") ~ "post_covid"))# Summarise by health board and COVID phase
pre_post_data <- key_months_data %>%
group_by(HBname, covid_phase) %>%
summarise(avg_qph = mean(quantity_per_head, na.rm = TRUE),
avg_simd = mean(SIMD2020v2_Decile, na.rm = TRUE)) %>%
pivot_wider(names_from = covid_phase, values_from = avg_qph) %>% # Pivot to get Pre and Post columns for connecting lines
mutate(percent_change = round(((post_covid - pre_covid)/pre_covid)*100, 2)) %>%
arrange(desc(avg_simd)) %>% # Rank from least to most deprived
ungroup() %>% # Before creating a factor so HBname can be arranged in order of avg_simd in graph
mutate(HBname = factor(HBname, levels = HBname)) # Create factor to preserve order of rows in plot# Plot lollipop graph
lollipop_graph <- pre_post_data %>%
ggplot() +
geom_segment(aes(x = HBname, xend = HBname, y = pre_covid, yend = post_covid),
color = "grey") +
geom_point(aes(x = HBname, y = pre_covid,
text = round(pre_covid, 2)), # display when graph hovered over
color = "orange", size = 3) +
geom_point(aes(x = HBname, y = post_covid,
text = round(post_covid, 2)), # display when graph hovered over
color = "purple", size = 3) +
coord_flip() +
theme_minimal() +
theme(plot.title = element_text(face = "bold")) +
xlab("Health Boards (least to most deprived)") +
ylab("Average Quantity Per Head") +
ggtitle("Change in Type 2 Diabetes Prescribing Pre- and Post-COVID\nHealth Boards Ranked by Deprivaton")
# Convert to interactive graph
lollipop_interactive <- ggplotly(lollipop_graph, tooltip = "text")
lollipop_interactiveHover over each point to view corresponding pre- and post-COVID values
Figure 3.2 illustrates a clear gradient whereby more deprived Health Boards consistently exhibited higher prescribing levels both before and after COVID-19. Ayrshire and Arran, the most deprived Health Board, recorded the highest post-COVID average quantity per head (4.69). The Western Isles, ranked fourth in deprivation, showed the largest absolute increase (0.86) between pre- and post-COVID periods. In contrast, Grampian and Shetland, the two least deprived Health Boards, had the lowest post-COVID average quantities per head (3.34), with Shetland showing the smallest increase (0.42). This pattern suggests that although prescribing increased across all Health Boards, existing socioeconomic gradients in Type 2 diabetes medication use remained evident.
However, absolute increases are heavily influenced by population size. To assess the severity of change across boards, percentage increases were examined to provide insights into how dramatically prescribing rose relative to pre-COVID levels, independent of baseline prescribing levels.
# Load NHS Health board Shapefile
NHS_healthboards <- suppressMessages(st_read(here("data/Week6_NHS_HealthBoards_2019.shp"), quiet = TRUE)) # Reads in file and hides message
# Join spatial data with other health data
summary_map <- NHS_healthboards %>%
full_join(pre_post_data, by = join_by(HBName == HBname)) %>%
rename(HBname = HBName) # Change column name for consistency# Plot percentage change map
plot_map <- summary_map %>%
ggplot() +
geom_sf(aes(fill = percent_change, text = paste0("Health Board: ", HBname, "\n", round(percent_change,2), "%")), size = 0.3) +
scale_fill_viridis_c(option = "plasma",
name = "% Change") +
labs(
title = "Percentage Change in Average Type 2 Diabetes Prescriptions Per Head\n Pre-COVID → Post-COVID by NHS Health Boards"
) +
theme_minimal() +
theme(legend.position = "right", plot.title = element_text(face = "bold"))
interactive_map <- ggplotly(plot_map, tooltip = "text")
interactive_mapHover over map to view Health Board name and corresponding percentage change
When examining percentage changes (Figure 3.3), the Western Isles showed the largest proportional rise at 29.00%, despite not having the highest baseline prescribing levels. Other Health Boards with relatively high increases included Lothian (24.28%), Highland (23.48%), Grampian (22.70%), and Tayside (21.06%), indicating substantial post-COVID growth across a mix of both urban and rural regions. In contrast, Shetland had the smallest proportional increase at 14.44%, with Ayrshire and Arran and Forth Valley showing more moderate rises of 18.79% and 20.79%, respectively.
Several Health Boards in the South of Scotland also demonstrated comparatively lower percentage changes. Dumfries and Galloway increased by 17.98%, while the Borders showed a rise of 20.00%, both noticeably smaller than the increases observed in more deprived central belt Health Boards such as Greater Glasgow and Clyde (19.25%) and Lanarkshire (17.80%).
To integrate these findings, a summary table presented below, showing each Health Board’s deprivation rank, baseline prescribing, and the observed absolute and percentage increases, allowing direct comparison across boards.
# Create summary table to be printed
ranked_table <- pre_post_data %>%
arrange(avg_simd) %>%
mutate(Rank = row_number(),
absolute_change = round(post_covid - pre_covid, 2)) %>%
select(c(Rank, HBname, pre_covid, absolute_change, percent_change)) # Select columns in order to be displayed# Create gt table
ranked_table %>%
gt() %>%
cols_label(
Rank = html("Rank<br>(Most to Least Deprived)"), # HTML break for cleaner layout
HBname = "NHS Health Board",
pre_covid = html("Pre-COVID Level<br>(per head)"),
absolute_change = "Absolute Increase",
percent_change = "Percentage Increase (%)"
) %>%
fmt_number(
columns = c(pre_covid),
decimals = 2) %>%
tab_header(
title = " NHS Health Boards by Percentage Increase in Type 2 Diabetes Prescriptions",
subtitle = "Comparing pre-COVID (Jan 2020) to post-COVID (Dec 2021)"
) %>%
# Colour scale for Absolute Increase
data_color(
columns = absolute_change,
method = "numeric",
palette = "Oranges"
) %>%
# Colour scale for Percentage Increase
data_color(
columns = percent_change,
method = "numeric",
palette = "Purples"
)| NHS Health Boards by Percentage Increase in Type 2 Diabetes Prescriptions | ||||
| Comparing pre-COVID (Jan 2020) to post-COVID (Dec 2021) | ||||
| Rank (Most to Least Deprived) |
NHS Health Board | Pre-COVID Level (per head) |
Absolute Increase | Percentage Increase (%) |
|---|---|---|---|---|
| 1 | Ayrshire and Arran | 3.95 | 0.74 | 18.79 |
| 2 | Lanarkshire | 3.46 | 0.62 | 17.80 |
| 3 | Greater Glasgow and Clyde | 3.42 | 0.66 | 19.25 |
| 4 | Western Isles | 2.98 | 0.86 | 29.00 |
| 5 | Dumfries and Galloway | 3.48 | 0.63 | 17.98 |
| 6 | Fife | 3.09 | 0.56 | 18.01 |
| 7 | Tayside | 2.89 | 0.61 | 21.06 |
| 8 | Highland | 2.95 | 0.69 | 23.48 |
| 9 | Forth Valley | 3.57 | 0.74 | 20.79 |
| 10 | Borders | 3.28 | 0.66 | 20.00 |
| 11 | Orkney | 3.35 | 0.64 | 19.25 |
| 12 | Lothian | 2.72 | 0.66 | 24.28 |
| 13 | Shetland | 2.92 | 0.42 | 14.44 |
| 14 | Grampian | 2.72 | 0.62 | 22.70 |
Analysis of Type 2 diabetes prescribing during the COVID-19 pandemic reveals clear temporal fluctuations closely aligned with national lockdowns. For instance, early 2021 saw a sharp decline in prescriptions corresponding to the third lockdown, likely reflecting reduced face-to-face appointments, interruptions to routine monitoring, and shifts in clinical priorities that limited opportunities for medication review and initiation (Figure 3.1). Once restrictions eased, most Health Boards experienced a rebound in prescribing, indicating a catch-up effect in routine diabetes care (Figures 3.1 and 3.2).
The recovery, however, was uneven across regions. While Ayrshire and Arran consistently had the highest prescribing levels and Grampian and Shetland the lowest, post-COVID prescribing generally exceeded pre-pandemic levels across all Health Boards, suggesting a system-wide restoration of services without substantially worsening existing inequalities (Figure 3.2). Yet, the magnitude of proportional increases varied by deprivation status: more deprived or mixed-deprivation areas such as the Western Isles, Highland, and Lothian showed notably larger percentage increases, indicating these regions may have experienced more delayed or deferred care during the pandemic (Figure 3.3). In contrast, less deprived areas, particularly Shetland, had smaller proportional changes, implying relatively consistent access to services or faster recovery.
Combining absolute and proportional changes highlights distinctive regional trajectories. The Western Isles, for example, recorded both the largest absolute and proportional increases, even though it is not the most deprived board, underscoring the influence of local factors beyond socioeconomic status (Figure 3.4). Across other boards, substantial variation persisted regardless of deprivation, suggesting that geography, population dispersion, workforce pressures, and local service organisation played critical roles in shaping recovery patterns. Together, these trends indicate that while socioeconomic deprivation remains an important determinant of prescribing levels, post-pandemic recovery was also shaped by broader structural and operational factors within each Health Board (Figures 3.3 and 3.4).
There are several limitations to this study. Regional differences in prescribing patterns may be influenced by confounders such as local health policies, medication availability, or access to healthcare settings. Additionally, only two time points are compared, so fluctuations during the pandemic are not captured. Finally, average SIMD scores showed little variation, requiring deprivation to be ranked rather than categorized into low- to high-deprived groups.
Future studies could include multiple time points throughout the pandemic to capture fluctuations and provide a more detailed picture of prescribing trends. Additionally, to better understand variation across deprived areas, deprivation should be examined at a smaller geographic scale than Health Boards.
National Records of Scotland (2022). Scottish Census. Scottish Census Web Portal. https://www.scotlandscensus.gov.uk/webapi/jsf/tableView/tableView.xhtml
Public Health Scotland (2025). Prescriptions in the Community. NHS Scotland Open Data. https://www.opendata.nhs.scot/dataset/prescriptions-in-the-community
Scottish Government (2020). Diabetes in Scotland: a rising tide. The Lancet Diabetes & Endocrinology 8, 769-770. https://doi.org/10.1016/S2213-8587(20)30124-8
Scottish Government (2020). Scottish Index of Multiple Deprivation 2020v2 data zone lookup file. Scottish Government Supporting Documents. https://www.gov.scot/collections/scottish-index-of-multiple-deprivation-2020/#supportingdocuments
UK Government (2025). NHS Health Boards Scotland. Data.gov.uk. https://www.data.gov.uk/dataset/27d0fe5f-79bb-4116-aec9-a8e565ff756a/nhs-health-boards-scotland
Williams R, Walker J, Smith K, Brown L (2023). The effect of the COVID-19 pandemic on HbA1c testing: prioritization of high risk cases and impact of social deprivation. Diabetes Therapy 14, 1231-1245. https://doi.org/10.1007/s13300-023-01380-x
## R version 4.5.1 (2025-06-13)
## Platform: aarch64-apple-darwin20
## Running under: macOS Sequoia 15.3.2
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.1
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: Europe/London
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] scales_1.4.0 plotly_4.11.0 sf_1.0-21 readxl_1.4.5
## [5] here_1.0.2 gt_1.1.0 janitor_2.2.1 lubridate_1.9.4
## [9] forcats_1.0.0 stringr_1.5.2 dplyr_1.1.4 purrr_1.1.0
## [13] readr_2.1.5 tidyr_1.3.1 tibble_3.3.0 ggplot2_4.0.0
## [17] tidyverse_2.0.0
##
## loaded via a namespace (and not attached):
## [1] gtable_0.3.6 xfun_0.53 bslib_0.9.0 htmlwidgets_1.6.4
## [5] tzdb_0.5.0 crosstalk_1.2.2 vctrs_0.6.5 tools_4.5.1
## [9] generics_0.1.4 parallel_4.5.1 proxy_0.4-27 pkgconfig_2.0.3
## [13] KernSmooth_2.23-26 data.table_1.17.8 RColorBrewer_1.1-3 S7_0.2.0
## [17] lifecycle_1.0.4 compiler_4.5.1 farver_2.1.2 snakecase_0.11.1
## [21] htmltools_0.5.8.1 class_7.3-23 sass_0.4.10 yaml_2.3.10
## [25] lazyeval_0.2.2 crayon_1.5.3 pillar_1.11.1 jquerylib_0.1.4
## [29] classInt_0.4-11 cachem_1.1.0 tidyselect_1.2.1 digest_0.6.37
## [33] stringi_1.8.7 labeling_0.4.3 rprojroot_2.1.1 fastmap_1.2.0
## [37] grid_4.5.1 cli_3.6.5 magrittr_2.0.4 e1071_1.7-16
## [41] withr_3.0.2 bit64_4.6.0-1 timechange_0.3.0 rmarkdown_2.29
## [45] httr_1.4.7 bit_4.6.0 cellranger_1.1.0 hms_1.1.3
## [49] evaluate_1.0.5 knitr_1.50 viridisLite_0.4.2 rlang_1.1.6
## [53] Rcpp_1.1.0 glue_1.8.0 DBI_1.2.3 xml2_1.4.0
## [57] vroom_1.6.5 rstudioapi_0.17.1 jsonlite_2.0.0 R6_2.6.1
## [61] fs_1.6.6 units_1.0-0